package com.quant.controller;

import com.quant.entity.dashboard.DashboardData;
import com.quant.service.BacktestService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author lu
 * @version 1.0
 * @date 2025/10/10 16:37
 * @describe
 */
@RestController
@RequestMapping("/api/chart")
@RequiredArgsConstructor
public class DashboardController {

	private final BacktestService backtestService;

	@GetMapping("/dashboard")
	public ResponseEntity<DashboardData> getDashboardData(
			@RequestParam(required = false) String taskId) {
		// 如果提供了taskId，查询指定回测任务的结果
		// 否则查询最新的回测结果
		DashboardData data = backtestService.getDashboardData(taskId);
		return ResponseEntity.ok(data);
	}
}
